<template>
	<view class="mainpadding beijingse">
		<view class="flexbetween">
			<view class="ffffff radius mainpadding wushi">
				<view class="huisetext textcenter">今日收益</view>
				<view class="heisetext textcenter margin_top">{{personInfo.styc_today_sy?personInfo.styc_today_sy:'0.00'}}</view>
			</view>
			<view class="ffffff radius mainpadding wushi" @click="tztx">
				<view class="flexcenter">
					<view class="huisetext textcenter">可提现收益</view>
					<view class="righticon"> </view>
				</view>
				<view class="heisetext textcenter margin_top">{{sy_price?sy_price:'0.00'}}</view>
			</view>
			<view class="ffffff radius mainpadding wushi" @click="tztxclick">
				<view class="flexcenter">
					<view class="huisetext textcenter">我的本金</view>
					<view class="righticon"> </view>
				</view>
				<view class="heisetext textcenter margin_top">{{token_price?token_price:'0.00'}}</view>
			</view>
		</view>
		<view class="dingwei margin_top">
			<view class="titletext">收益详情</view>
			<view class="zitbjs"></view>
		</view>
		<view class="ffffff mainpadding radius mainpadding margin_top" v-if="list.data.length">
			<view class="xiahuax" v-for="item in list.data" :key="item.id">
				<view class="flexbetween">
					<view class="ershib1">{{item.memo}}</view>
					<view class="qianshu">{{item.token_price>0?'+'+item.token_price:item.token_price}}</view>
				</view>
				<view class="flexbetween margin_top1">
					<view class="qhtext">{{item.createtime_text}}</view>
					<view class="qhtext">本金：{{item.bj_token_price}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				page: 1,
				limit: 12,
				styc_account_id:"",
				sy_price:"",
				list: {
					data: []
				},
				token_price:"",
				personInfo:{
					styc_today_sy:"",
				}
			}
		},
		onLoad(option){
			this.styc_account_id=option.styc_account_id
		},
		onShow() {
			this.getinfo()
			this.init()
		},
		methods: {
			getinfo() {
				httpRequest.request('/api/user/index', 'POST', {}, false, false, true).then(res => {
					if (res.code == 1) {
						this.personInfo = res.data
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
				httpRequest.request('/api/stycorder/myStycDetail', 'POST', {
					id:this.styc_account_id
				}, false, false, true).then(res => {
					if (res.code == 1) {
						this.sy_price=res.data.sy_price
						this.token_price=res.data.token_price
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			init(isPage, page) {
				let _this = this;
				httpRequest.request('/api/stycorder/stycRecord', 'POST', {
					page: page || 1,
					limit: _this.limit,
					type:1,
					styc_account_id:this.styc_account_id,
				}, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			// 跳转我的本金提现
			tztxclick() {
				uni.navigateTo({
					url: '/pages/mypage/tixian?type=3&styc_account_id='+this.styc_account_id
				})
			},
			// 跳转s收益提现
			tztx() {
				uni.navigateTo({
					url: '/pages/mypage/tixian?type=4&styc_account_id='+this.styc_account_id
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.xiahuax {
		margin-top: 30rpx;
		padding-bottom: 30rpx;
		border-bottom: 2rpx solid rgba(0, 0, 0, 0.03);
	}

	.xiahuax:first-child {
		margin-top: 0rpx;
	}

	.xiahuax:last-child {
		padding-bottom: 0rpx;
		border-bottom: none;
	}

	.qhtext {
		font-size: 24rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #999999;
	}

	.qianshu {
		font-size: 32rpx;
		font-family: DIN Next LT Pro-Bold, DIN Next LT Pro;
		font-weight: bold;
		color: #FAB536;
	}

	.ershib1 {
		font-size: 28rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #333333;
	}

	.wushi {
		// width:30%;
		flex-grow: 1;
	}
	.wushi:nth-child(2){
		margin: 0 13rpx;
	}

	.heisetext {
		font-size: 34rpx;
		font-family: DIN Next LT Pro-Bold, DIN Next LT Pro;
		font-weight: bold;
		color: #000000;
	}

	.huisetext {
		font-size: 24rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #999999;
		margin-right: 6rpx;
	}
</style>
